import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import s_get from '@dfeidao/atom-web/storage/get';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// import show_loading from '../../atom-web/show-loading';
// import hide_loading from '../../atom-web/hide-loading';
import p001 from './p001';
import p002 from './p002';
// ec-002
export default async function a003(fd: IFeidaoAiBrowserComponent) {

	// const user = await whoami(get_user_info);
	// console.log(user)
	const prid = await s_get('productid');

	const query = {
		filter: { productid: prid }
	};
	// 没有数据
	// show_loading();
	// const res = await nodejs<{ dataArray: object[] }>(url, './permissions/role_type_find', query, false, false);
	// hide_loading();
	const res = await nodejs<{ dataArray: object[] }>('role-type/zj-000001/s001', query);
	// 无数据渲染p002
	if (res.dataArray.length === 0) {

		render(fd, {}, p002, 'p002', 'inner');
		render(fd, {}, p001, 'p001', 'inner');
	} else {
		const tb = res.dataArray;
		const data = tb.map((v) => {
			return { ...v, v: JSON.stringify(v) };
		});
		fd.data.node.querySelector('[data-feidao-presentation="p002"]').innerHTML = '';
		render(fd, data, p001, 'p001', 'inner');

	}
}
